<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								线路名称：<input type="text" name="name"/>
							</li>

							<!--<li>
								运行编号：<input type="text" name="runCode"/>
							</li>-->

							<li>
								线路类型：<select id="lineType"  name="lineType">
									<option value="">请选择</option>
									<option value="架空线">架空线</option>
									<option value="电缆线">电缆线</option>
								</select>

							</li>

							<li>
								电压等级：<select id="voltage"  name="voltage">
									<option value="">请选择</option>
									<option value="10kv">10kv</option>
									<option value="400v">400v</option>
									<option value="220v">220v</option>
								</select>

							</li>

							<!--<li>
								线路总长度：<input type="text" name="totalSpan"/>
							</li>

							<li>
								架空线路总长度：<input type="text" name="overSpan"/>
							</li>

							<li>
								电缆总长度：<input type="text" name="cableSpan"/>
							</li>

							<li>
								变压器ID：<input type="text" name="byqId"/>
							</li>-->

							<!--<li>
								上级线路ID：<input type="text" name="upLineId"/>
							</li>-->

							<!--<li>
								资产单位：<input type="text" name="unit"/>
							</li>

							<li>
								运维班组：<input type="text" name="runTeam"/>
							</li>

							<li>
								创建人：<input type="text" name="addUser"/>
							</li>

							<li>
								创建日期：<input type="date" name="addDate"/>
							</li>

							<li>
								最近更新人：<input type="text" name="updateUser"/>
							</li>

							<li>
								最近更新日期：<input type="date" name="updateDate"/>
							</li>

							<li>
								数据状态：<input type="text" name="datastate"/>
							</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="assets:iLine:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.editFull()" shiro:hasPermission="assets:iLine:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="assets:iLine:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="assets:iLine:export">
						<i class="fa fa-download"></i> 导出
				 </a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('assets:iLine:edit')}]];
        var removeFlag = [[${@permission.hasPermi('assets:iLine:remove')}]];
        var voltageGradeDatas = [[${@dict.getType('voltage_grade')}]];
        var lineType = [[${@dict.getType('line_type')}]];
        var prefix = ctx + "assets/iLine";
		var upLine = null;
		var byq = null;

        $(function() {

            $.post(ctx + "assets/b10kvLineInfo/getLineName", function (r) {
                upLine = r.b10kvLineInfo;
            });
            $.post(ctx + "assets/bByq/getByqName", function (r) {
                byq = r.bByqList;
            });

            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                showSearch:false,		//是否显示检索信息
                showRefresh:false,		//是否显示刷新按钮
                showToggle:false,		//是否显示详细视图和列表视图的切换按钮
                showColumns:false,		//是否显示隐藏某列下拉框
                sortable:false,		//是否启用排序
                modalName: "低压线路",
//		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'id',
					visible: false
				},
				{
					field : 'name', 
					title : '线路名称',
					sortable: true
				},
				{
					field : 'runCode', 
					title : '运行编号',
					sortable: true
				},
				{
					field : 'lineType', 
					title : '线路类型',
					sortable: true,
                    formatter: function (value, row, index) {
					    return value;
//                        return $.table.selectDictLabel(lineType, value);
                    }
				},
				{
					field : 'voltage', 
					title : '电压等级',
					sortable: true,
                    formatter: function (value, row, index) {
					    return value;
//                        return $.table.selectDictLabel(voltageGradeDatas, value);
                    }
				},
				{
					field : 'totalSpan', 
					title : '线路总长度',
					sortable: true,
                    visible:false
				},
				{
					field : 'overSpan', 
					title : '架空线路总长度',
					sortable: true,
                    visible:false
				},
				{
					field : 'cableSpan', 
					title : '电缆总长度',
					sortable: true,
                    visible:false
				},
				{
					field : 'byqId', 
					title : '变压器',
					sortable: true,
                    formatter: function (value, row, index) {
                        for (index in byq) {
                            if (value == byq[index].id)
                                return byq[index].name;
                        }
                    }
				},
				{
					field : 'upLineId', 
					title : '上级线路',
					sortable: true,
                    formatter: function (value, row, index) {
                        for (index in upLine) {
                            if (value == upLine[index].id)
                                return upLine[index].name;
                        }
                    }
				},
				{
					field : 'unit', 
					title : '资产单位',
					sortable: true,
					visible:false
				},
				{
					field : 'runTeam', 
					title : '运维班组',
					sortable: true,
                    visible:false
				},
				{
					field : 'addUser', 
					title : '创建人',
					sortable: true,
                    visible: false
				},
				{
					field : 'addDate', 
					title : '创建日期',
					sortable: true,
                    formatter: function (value, row, index) {
                        return value!=null?new Date(value).Format('yyyy-MM-dd'):"";
                    }
				},
				{
					field : 'updateUser', 
					title : '最近更新人',
					sortable: true,
                    visible: false
				},
				{
					field : 'updateDate', 
					title : '最近更新日期',
					sortable: true,
                    formatter: function (value, row, index) {
                        return value!=null?new Date(value).Format('yyyy-MM-dd'):"";
                    },
                    visible: false
				},
				{
					field : 'datastate', 
					title : '数据状态',
					sortable: true,
                    visible: false
				},
		        {
		            title: '操作',
		            align: 'center',
					width:'240px',
		            formatter: function(value, row, index) {
		            	var actions = [];
//		            	actions.push('<a class="btn btn-warning btn-xs " href="#" onclick="exportAssets(\'' + row.id+'\',\'' + row.name + '\')"><i class="fa fa-download"></i>导出资产统计</a>');
//		            	actions.push('<a class="btn btn-warning btn-xs " href="#" onclick="exportLineAssets(\'' + row.id + '\',\'' + row.name + '\')"><i class="fa fa-download"></i>导出资产台账</a>');
//		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="exportDevice(\'' + row.id + '\')"><i class="fa fa-download"></i>导出设备</a> ');
//		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="exportMaterial(\'' + row.id + '\')"><i class="fa fa-download"></i>导出材料</a> ');
//		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="exportCad(\'' + row.id + '\')"><i class="fa fa-download"></i>导出单线图</a>');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join(' ');
		            }
		        }]
            };
            $.table.init(options);
        });



        /**
         * 	日期格式化
         */
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }




        /**
         * 	上级线路名称
         */
//		function upLine(value,row) {
			/*$.ajax({
				 url: ctx + "assets/b10kvLineInfo/getLineName",
				 type: "post",
				 dataType: "json",
				 data: {"id":value},
				 success: function (result) {
				 	console.log("结果=="+JSON.stringify(result))
				 }
			});*/
			/*$.post(ctx + "assets/b10kvLineInfo/getLineName",function(data,status){
				console.log("lineName=="+JSON.stringify(data))
				alert("Data: " + data + "nStatus: " + status);
			});*/
//		}



        /**
         * 	导出线路资产管理统计
         */
        function exportAssets(id,name) {
            var url = ctx+ "assets/exportDetiail/Assets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-资产管理统计表";
                    window.location.href = ctx + "assets/exportDetiail/common/download?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });

        }


        /**
         * 	导出线路资产台账
         */
        function exportLineAssets(id,name) {
            var url = ctx+ "assets/exportDetiail/LineAssets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-资产台账表";
                    window.location.href = ctx + "assets/exportDetiail/common/download?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });

        }


        /**
         * 	导出设备
         */
        function exportDevice(id) {

            console.log("线路ID=="+id)

            var url = ctx+ "assets/exportDetiail/Detailed";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    $.modal.msgSuccess("下载成功，文件路径："+data);
                }
            });

        }



        /**
         * 	导出材料
         */
        function exportMaterial(id) {

            console.log("线路ID11=="+id)

            var url = ctx+ "assets/exportDetiail/Material";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    $.modal.msgSuccess("下载成功，文件路径："+data);
                }
            });

        }


        /**
		 * 	导出dxf文件
         */
        function exportCad(id){
            console.log("线路ID11=="+id)

            var url = ctx+ "assets/exportCad/getAllPointInfo";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    $.modal.msgSuccess("下载成功，文件路径："+data);
                }
            });
		}



	</script>
</body>
</html>